package cn.wjssl.types.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 消息队列通用类
 */
@Data
public abstract class BaseEvent<T> {

    // 获取mq完整消息格式
    public abstract EventMessage<T> buildEventMessage(T data);

    // 发送的topic
    public abstract String topic();

    // 消息标准格式
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class EventMessage<T> {
        private String id;
        private Date timestamp;
        private T data;
    }
}
